package Red.Star.Fall;

import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.engine.camera.Camera;
import org.anddev.andengine.engine.options.EngineOptions;
import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.scene.background.ColorBackground;
import org.anddev.andengine.entity.text.Text;
import org.anddev.andengine.entity.util.FPSCounter;
import org.anddev.andengine.opengl.font.Font;
import org.anddev.andengine.opengl.texture.Texture;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.anddev.andengine.ui.activity.BaseGameActivity;
import org.anddev.andengine.util.HorizontalAlign;

import android.app.Activity;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;

public class RedStarFallActivity extends BaseGameActivity {
	private Camera _camera;
	private static final int HEIGHT = 480;
	private static final int WIDTH = 720;
	protected Texture _fontTexture;
	protected Font _font;
	
	public Engine onLoadEngine() {
		this._camera = new Camera(0, 0, WIDTH, HEIGHT);
		return new 	Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(WIDTH, HEIGHT), 
					this._camera));
	}

	public void onLoadResources() {
		this._fontTexture = new BitmapTextureAtlas(256, 256, TextureOptions.BILINEAR);
		this._font = new Font(this._fontTexture, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 32, true, Color.BLACK);
		
		this.getEngine().getTextureManager().loadTexture(this._fontTexture);
		this.getEngine().getFontManager().loadFont(this._font);
	}

	public Scene onLoadScene() {
		this.getEngine().registerUpdateHandler(new FPSCounter());
		
		final Scene scene = new Scene(1);
		scene.setBackground(new ColorBackground(0.09804f, 0.6274f, 0.8784f));
		final Text textCenter = new Text(100, 60, this._font, "this is a loading page", HorizontalAlign.CENTER);
		.getScene().attachChild(textCenter);
		return scene;
	}

	public void onLoadComplete() {
		
		
	}
    
}